const express=require("express");
var router=express.Router();
var pool=require("../pool");

router.get("/title",(req,res)=>{
  let bid=req.query.bid; 
  var sql="SELECT title FROM mx_book where bid=?";
  pool.query(sql,[bid],(err,result)=>{
    if(err){
      console.log(err);
    }
    res.send(result);
	 console.log(result);
  })
})

router.get("/",(req,res)=>{
  let bid=req.query.bid; 
  // let title=req.query.title
  var sql="SELECT * FROM mx_chapter where bid=? ";
  pool.query(sql,[bid],(err,result)=>{
    if(err){
      console.log(err);
    }
    res.send(result);
	 console.log(result);
  })
})
router.get("/cid",(req,res)=>{
  console.log(req.query)
  var sql=`SELECT * FROM mx_chapter where bid=${req.query.bid} limit ${req.query.num},1`;
  pool.query(sql,(err,result)=>{
    if(err){
      console.log(err);
    }
    res.send(result);
	// console.log(result);
  })
})

module.exports=router;